import React from 'react';
import { Tag } from 'antd';
import constant from '@/const';

export const getFormData = (that: any) => {
  const { searchLoading, userLevelList } = that.state;
  const formConfig = {
    searchLoading,
    config: [
      {
        id: 'date',
        type: 'daterange',
        options: {
          name: '注册时间',
          showTime: true,
          value: that.initDefaultDate(30),
          format: ['startDate', 'endDate'],
        },
      },
      {
        id: 'maxBalance',
        type: 'input-number',
        options: {
          name: '',
          width: 80,
          hidden: true,
          placeholder: '请输入',
          value: '',
        },
      },
      {
        id: 'minBalance',
        type: 'input-number',
        options: {
          name: '',
          width: 80,
          hidden: true,
          placeholder: '请输入',
          value: '',
        },
      },
      {
        id: 'input-number-group',
        type: 'input-number-group',
        options: {
          name: '主账户余额',
          value: '',
          prev: 'minBalance',
          next: 'maxBalance',
        },
      },
      {
        id: 'status',
        type: 'select',
        options: {
          name: '锁定状态',
          placeholder: '请选择锁定状态',
          value: -1,
          allowClear: false,
          list: constant.ACCOUNT_STATUS,
        },
      },
      {
        id: 'online',
        type: 'select',
        options: {
          name: '在线状态',
          placeholder: '请选择在线状态',
          value: -1,
          allowClear: false,
          list: constant.ONLINE_STATUS,
        },
      },
      {
        id: 'levelId',
        type: 'select',
        options: {
          name: '玩家层级',
          placeholder: '请选择玩家层级',
          value: '',
          allowClear: false,
          list: userLevelList || [],
        },
      },
      {
        id: 'searchType',
        type: 'select',
        options: {
          name: '',
          width: 115,
          placeholder: '',
          value: 1,
          hidden: true,
          allowClear: false,
          list: constant.USER_SEARCH_TYPE,
        },
      },
      {
        id: 'keywords',
        type: 'input',
        options: {
          name: '',
          value: '',
          width: 260,
          placeholder: '请输入关键词',
          addonBefore: 'searchType',
        },
      },
      {
        id: 'levelStatus',
        type: 'select',
        options: {
          name: '层级状态',
          placeholder: '请选择层级状态',
          value: '|',
          allowClear: false,
          list: constant.LEVEL_STATUS,
        },
      },
      {
        id: 'channelId',
        type: 'select',
        options: {
          name: '第三方平台',
          placeholder: '请选择第三方平台',
          value: '',
          allowClear: false,
          list: constant.TRANSFER_PLATFORMS.filter(i => i.value !== 101 && i.value !== 0),
        },
      },
      {
        id: 'thirdPartyUserName',
        type: 'input',
        options: {
          name: '第三方账户名',
          placeholder: '第三方账户名',
          value: '',
        },
      },
      {
        id: 'lockStatus',
        type: 'select',
        options: {
          name: 'VIP状态',
          placeholder: '请选择VIP状态',
          value: '|',
          allowClear: false,
          list: constant.MEMBER_VIP_STATUS,
        },
      },
      {
        id: 'submit',
        type: 'button',
        options: {
          name: '查询',
          type: 'primary',
        },
      },
      {
        id: 'reset',
        type: 'button',
        options: {
          name: '重置',
        },
      },
    ],
    requestList: that.requestList,
  };

  // 此处保存表单最初的默认值
  that.initDefaultFormParams({ formConfig });
  return formConfig;
};
